<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mmodesquire extends CI_Model{
    protected $table_name = 'app_esquire';
    function  __construct(){
        parent::__construct();
    }
    function countAll(){
        $this->db->from($this->table_name);
        $query = $this->db->get();
        return $query->num_rows();
    }
    function listAll($number, $offset){
        $this->db->from($this->table_name);
        $this->db->limit($number,$offset);
        $this->db->order_by('id','DESC');
        $query = $this->db->get();
        return $query->result_array();        
    }
    function listDetail($id){
        $this->db->from($this->table_name);
        $this->db->where('id',$id);
        $query = $this->db->get();
        return $query->row_array();
    }
    function listRandom(){
        $this->db->from($this->table_name);
        $this->db->limit('4');
        $this->db->order_by('id', 'RANDOM');
        $query = $this->db->get();
        return $query->result_array();        
    }
}